def read_genome(filename=""):
    fp = open(filename)
    lines = fp.readlines()
    return lines[0].replace("\n", ""), lines[1].replace("\n", "")


def pattern_count(text, pattern):
    ori_size = len(text)
    k_mer_size = len(pattern)

    count = 0
    for i in range(0, ori_size-k_mer_size):
        if text[i:i+k_mer_size] == pattern:
            count = count + 1

    return count


if __name__ == "__main__":

    filename = "dataset_2_6.txt"

    text, pattern = read_genome(filename)

    text, pattern = "CGCGATACGTTACATACATGATAGACCGCGCGCGATCATATCGCGATTATC", "CGCG"

    count = pattern_count(text, pattern)

    print(count)
